package org.luxor.eshop.order.service.hystrix;

import org.luxor.commons.core.web.RestStatus;
import org.luxor.commons.core.web.data.R;
import org.luxor.eshop.order.entity.dto.CommodityDto;
import org.luxor.eshop.order.entity.dto.DeductInventoryDto;
import org.luxor.eshop.order.service.StorageFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Collection;

/**
 * 熔断实现
 *
 * @author Mr.Yan  @date: 2020/9/2
 */
@Component
public class StorageHystrixImpl implements StorageFeign {
    private static Logger logger = LoggerFactory.getLogger(StorageHystrixImpl.class);

    @Override
    public R deductInventory(Collection<DeductInventoryDto> deductInventory) {
        logger.warn("deductInventory Method Response Hystrix Data");
        return R.failed(RestStatus.FEIGN_HYSTRIX);
    }

    @Override
    public R<CommodityDto> getByCommodityCode(String commodityCode) {
        logger.warn("getByCommodityCode Method Response Hystrix Data");
        return R.failed(RestStatus.FEIGN_HYSTRIX, new CommodityDto());
    }
}

